-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shrink SqlParameter XmlSchema #1033
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cheenamalhotra
approved these changes
Apr 28, 2021
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs
Outdated
Show resolved
Hide resolved
JRahnama
reviewed
May 3, 2021
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs
Show resolved
Hide resolved
JRahnama
reviewed
May 3, 2021
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlParameter.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlParameter.cs
Outdated
Show resolved
Hide resolved
DavoudEshtehari
approved these changes
May 3, 2021
JRahnama
approved these changes
May 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In dotnet/corefx#35549 I changed
SqlParameter
to useSqlMetaDataXmlSchemaCollection
to hold xml schema information if it is present. This reduces the memory size because rather than keeping 3 string references which will mostly be null a single reference is kept for the sub object and it is created before use. This ports that change to netcore and netfx and adds the covering tests, it includes the fixes from dotnet/corefx#41008 which covered a problem in the original.While working on
SqlParameter
i made a couple of other minor changes:The direction field was not initialized but had a getter which checked for the 0 value and then returned ParameterDirection.Input. Recent profiling work on parameter passing showed that getting the parameter direction is an unexpectedly hot call. Because it is not possible for users to observe the 0 value it is safe to simply initialize the value in the ctors and then use a simple getter. The only observable change in this is if a user changes the value and is using INotifyPropertyChanged (usually designers use this) they will now not see a change from 0 to 1 if they assign to the Direction property, given that they could never observe the 0 value this seems like it is unlikely to break anyone.
The ctor call chain in netfx and netcore was slightly different so I synchronized them. This should have no practical effect but it will make merging the files later easier.
I removed some uses of
ADP.StrEmpty
and replaced them withstring.Empty
, these two expressions point to the same string instance because of runtime interning of constant strings. Using our own alias for it is no more secure than referring to it asstring.Empty
or""
, as such just use the runtime supported constant and remove our copy from the library at some future date when all other references have been removed.